package com.jan.client;

import java.io.IOException;
import java.net.Socket;

public class Client
{
  private static String id;

  /**
   * TODO
   * @throws IOException 
   *
   */
  public static void main(String[] args) throws IOException
  {
    System.out.println("请输入您的ID:");
    byte[] ibs=new byte[1024];
    int ilength=System.in.read(ibs);
    id=new String(ibs,0,ilength-2);
    DataPacket packet=new DataPacket(id,"10000","");
    SendHandle.add(packet);
    try
    {
      Socket socket=new Socket("127.0.0.1",1314);
      Thread sendThread=new Thread(new SendHandle(socket));
      Thread reciveThread=new Thread(new ReciveHandle(socket));
      sendThread.start();
      reciveThread.start();
    }
    catch (IOException e)
    {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    while(true){
      byte[] bs=new byte[1024];
      int length=System.in.read(bs);
      packet=new DataPacket(id,"10002",new String(bs,0,length));
      SendHandle.add(packet);
    }

  }

}
